/**
 * Created by Administrator on 2016/3/8.
 */

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		}
	}
	return ""
}
//设置cookie
function setCookie(cname, cvalue, exdays) {
	var d = new Date();
	d.setTime(d.getTime() + (exdays*24*60*60*1000));
	var expires = "expires="+d.toUTCString();
	document.cookie = cname + "=" + cvalue + "; " + expires;
}
function clearCookie(name) {
	setCookie(name, "", -1);
}
$(document).ready(function(){
	var Name = location.href.split('?')[1];
	var uName=decodeURI(Name);

    var loginInfo = JSON.parse(getCookie("loginInfo"));
    loginInfo = JSON.parse(loginInfo);
    var userName = loginInfo.userName;
    if(!userName) {
        userName = "admin";
    }
	if(userName=="" || userName=="undefined"){
		//alert(1)
		$(".login-and-sign").show();
		$(".index_logo_box_right").hide();
	}else if(userName!==""){
		//var userName=decodeURI(Name);
		//alert(2)
		//console.log(uName);
		$(".login-and-sign").hide();
		$(".index_logo_box_right").show();
		$(".index_right_menu_name").html("<em>" + userName + "</em>");
	}

	$(".index_logo_box_right_quit span").click(function(){
		clearCookie();
		$(".login-and-sign").show();
		$(".index_logo_box_right").hide();
		$(".index_right_menu_name em").html("");
	})

});

